<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

class sfActionsEx extends sfActions{
    protected function prepareRequest(sfRequest $request, $posts){
        $object = new stdClass();
        $object->posts = $posts;
        $values = array();
        $empty = array();
        foreach($posts as $post){
            if($request->getParameter($post) != NULL){
                $values[$post] = $request->getParameter($post);
            }
            else if($empty){
                $empty[$post] = $post;
            }
        }
        $object->values = $values;
        $object->empty = $empty;
        if(count($values) === 0){
            $object->status = 0;
        }
        else if(count($values) < count($posts)){
            $object->status = 1;
        }
        else{
            $object->status = 2;
        }
        return $object;
    }
    
    public function preExecute() {
        myBucket::getInstance()->setUser($this->getUser());
        parent::preExecute();     
    }
    
    
    protected function getPresentation($viewName = sfView::SUCCESS) {
        $view = $this->getController()->getView($this->getContext()->getModuleName(), $this->getContext()->getActionName(), $viewName);
        $view->execute();
        $view->getAttributeHolder()->add($this->getVarHolder()->getAll());
        return $view->render();
    }
}